<?php
namespace app\service;
// +----------------------------------------------------------------------
// | bbcThink
// +----------------------------------------------------------------------
// | Copyright (c) 2025 http://bbcweb.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: bbcweb <22745529@qq.com>
// +----------------------------------------------------------------------
use think\facade\Db;

//菜单
class MenuService
{
    public static function index($param)
    {
        $data_list = Db::table('lb_menu')->where(['is_show'=>$param['is_show'],'parent_id'=>$param['parent_id']])->select()->toArray();
        return $data_list;
    }
    public static function getTreeList($param=null)
    {
        $data = Db::table('lb_menu')->where(['pid'=>0])->where($param['where'])->order('sort asc')->select()->toArray();
        $list=array();
        foreach($data as &$v)
        {
            $v['spl']='';
            array_push($list,$v);
            $menu=Db::table('lb_menu')->where(['pid'=>$v['id']])->order('sort asc')->select()->toArray();
            foreach($menu as &$vv)
            {
                $vv['spl']='　├　';
                array_push($list,$vv);
                $menu2=Db::table('lb_menu')->where(['pid'=>$vv['id']])->order('sort asc')->select()->toArray();      
                foreach($menu2 as &$vvv)
                {
                    $vvv['spl']='　├　　├　';
                    array_push($list,$vvv);
                }
            }
        }
        return $list;
    }
}